<template>
  <div class="page">
    <div class="header">
       <el-button type="primary" @click="getback()">返回</el-button>
      <el-button type="primary" @click="routerPath()">指标录入</el-button>
    </div>
    <div class="main">
      <!-- <div class="subnav">
        <div class="searchLeft">
          <el-input
            v-model="input"
            placeholder="请输入内容"
            style="width:295px;"
          ></el-input>
          <button>搜索</button>
        </div>
        <div class="searchRight">
          <span>任务名称</span>
          <el-select v-model="value" placeholder="请选择" size="medium">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>

          <el-select v-model="value" placeholder="请选择" size="medium">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </div>
      </div> -->
      <div class="list" id="indicatorsList">
        <el-scrollbar class="page-component__scroll" style="height:100%">
          <div style="height:700px;">
            <el-table
              ref="multipleTable"
              :data="tableData"
              tooltip-effect="dark"
              height="600"
              style="width: 100%"
              @selection-change="handleSelectionChange"
            >
              <el-table-column type="selection" width="55"> </el-table-column>
              <el-table-column prop="districtName" label="区县">
              </el-table-column>
              <el-table-column prop="departmentName" label="责任单位">
              </el-table-column>
              <el-table-column prop="number" label="任务量"> </el-table-column>
              <el-table-column prop="remarks" label="任务描述">
              </el-table-column>
              <el-table-column prop="completeQuarter" label="完成季度">
              </el-table-column>
              <el-table-column label="操作">
                <template slot-scope="scope"> 
                  <el-button
                    type="success"
                    size="mini"
                    @click="handleAmend(scope.row)"
                    >修改</el-button
                  >
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-scrollbar>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      pageNum: 1, //第几页
      pageSize: 10, //每页几条
      total: 0, //条数
      options: [],
      value: "",
      input: "",
      tableData: [],
      multipleSelection: [],
      currentPage1: 5,
      currentPage2: 5,
      currentPage3: 5,
      currentPage4: 4,
      ID: ""
    };
  },
  mounted() {
    this.ID = this.$route.query.id;
    this.getListByPage();
  },
  methods: {
    getback(){
       this.$router.push({
        path: "/indicatorsList",
        
      });
    },
    dataTotal(val) {
      this.pageNum = val;
    },
    // 列表查看
    handexamine(val) {
      console.log(val);
    },
    handleAmend(val) {
      console.log(val);
      let _id = this.$route.query.parnetid
      this.$router.push({
        path: "/RecordList",
        query: {
          id: _id
        }
      });
    },
    // 删除
    handleDelete(val) {
      //POST /distribution/remove
      let _obj = {
        id: val.id
      };
      this.$axios
        .post("/distribution/remove", _obj)
        .then(res => {
          if (res.code == 200) {
            this.getListByPage();
            this.$message({
              message: "数据更新成功",
              type: "success"
            });
            console.log(res);
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    // 获取数据列表
    getListByPage() {
      let _obj = {
        subtasksId: this.ID
      };
      this.$axios
        .post("/deptTask/getList")
        .then(res => {
          if (res.code == 200) {
            console.log(res);
            this.tableData = res.data;
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    // 表格数组
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    // / 跳转页面
    routerPath() {
      this.$router.push("/RecordList");
    }
  }
};
</script>
<style scoped>
.page {
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.header {
  float: left;
  width: 100%;
  height: 52px;
  text-align: left;
  background: rgb(252, 248, 248);
}
.main {
  width: 100%;
  height: 100%;
  padding: 0 20px;
  padding-top: 52px;
  background: #fff;
}
.subnav {
  float: left;
  width: 100%;
  height: 60px;
  line-height: 60px;
  padding: 0 20%;
}
.searchLeft {
  float: left;
  width: 400px;
  /* height: 40px; */
}
.searchLeft > button {
  width: 100px;
  height: 40px;
  background: #409eff;
  color: #fff;
  border: 0px;
  font-size: 16px;
  text-align: center;
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
  position: relative;
  left: -8px;
  top: 1px;
}
.searchRight {
  float: left;
  width: auto;
}
.searchRight > span {
  display: inline-block;
  width: 80px;
  height: auto;
  font-size: 14px;
  text-align: center;
  margin-left: 20px;
}
.el-scrollbar__wrap {
  overflow-x: hidden;
}
.page-component__scroll {
  height: 100%;
}
.list {
  width: 100%;
  height: 100%;
  padding-top: 60px;
  padding-bottom: 60px;
}
.laypage {
  width: 100%;
  height: 60px;
  position: relative;
  top: -60px;
  text-align: right;
}
</style>
<style>
#indicatorsList .el-scrollbar__wrap {
  overflow: visible;
  overflow-y: scroll;
}
</style>
